* Stata code for regression analyses of discernment (decomposed and truth discernment, hypotheses H3* and H4*)
* Date: 17 March 2025

set more off
clear all
version 18

*1. Data Preparation 
** Importing data  **

import excel "final_merged_crmisinfo.xlsx", sheet("Sheet1") firstrow case(lower)

** Reshaping data from wide to long format to generate headline-person-level data **
reshape long pre@_true_reliable pre@_true_conf pre@_true_share pre@_false_reliable pre@_false_conf pre@_false_share post@_true_reliable post@_true_conf post@_true_share post@_false_reliable post@_false_conf post@_false_share post@_text fluavg creatavg mvalavg taskappavg, i(pid) j(headline)

** Changing order of variables **
order pre_true_reliable pre_true_conf pre_true_share pre_false_reliable pre_false_conf pre_false_share post_true_reliable post_true_conf post_true_share post_false_reliable post_false_conf post_false_share post_text fluavg creatavg mvalavg taskappavg, a(nationality)

** Creating time and post type variables **
ren pre_* *_1
ren post_* *_2


*** Reshaping to generate time (baseline-endline) variable **
reshape long true_reliable_ true_conf_ true_share_ false_reliable_ false_conf_ false_share_, i(pid headline) j(time)
ren true_* *1
ren false_* *2

*** Reshaping to generate post type (true/false) variable **
reshape long reliable_ conf_ share_, i(pid headline time) j(posttype)
*Changing order 
order condition, a(posttype)

** Labeling **
label define time 1 "Pre" 2 "Post"
label values time time
label define posttype 1 "True
label define posttype 1 "True" 2 "False", modify
label values posttype posttype
encode condition, g(treat)

** Additional coding for sex, education, nationality **
gen female = (gender==2)
replace female =. if gender>=3
replace female = 1+female
codebook edu
recode edu (7=.)

** To identified Indian sample **
gen nation = 1 if nationality==1
replace nation = 2 if nationality==2 | nationality==3
label define nation 1 "Indian" 2 "Non-Indian"
label values nation nation

*export excel using "crmisinfo_creat", firstrow(variables)

** Variable lists for regressions - only continupus variables **
vl create sociod = (age edu)
vl create cov = (cse_total pi_cultural_total pi_obedience_total pi_selfreport)
vl create pers = (decep_total mach_total narc_total psych_total sadism_total)
vl create creat = (fluavg creatavg mvalavg taskappavg)

** Labeling 
*ssc install labvars
labvars female age edu cse_total pi_cultural_total pi_obedience_total pi_selfreport decep_total mach_total narc_total psych_total sadism_total "Female" "Age" "Education" "CSE" "PI_Cultural" "PI_Obedience" "Self-report PI" "Deception" "Machiavellianism" "Narcissism" "Psychopathy" "Sadism"

labvars creatavg mvalavg taskappavg fluavg "Creativity" "Moral Valence" "Task Appr." "Fluency"


*************************************************************************************************************************************************************
*************************************************************************************************************************************************************
*************************************************************************************************************************************************************

*2. Data Analyses - India
preserve
keep if nation==1

** Step-wise regressions for 
foreach var in reliable_ share_ conf_ {
qui reg `var' b(1).treat##b(1).time##b(2).posttype, cluster(pid)
est store `var'_add1
outreg2 using `var'_discernment.xls, excel append label alpha(0.001, 0.01, 0.05)
qui meglm `var' b(1).treat##b(1).time##b(2).posttype, family(poisson) link(log) vce(cluster pid)
est store `var'_mult1
outreg2 using `var'_discernment.xls, excel append label alpha(0.001, 0.01, 0.05)

qui reg `var' b(1).treat##b(1).time##b(2).posttype i.female $sociod, cluster(pid)
est store `var'_add2
outreg2 using `var'_discernment.xls, excel append label alpha(0.001, 0.01, 0.05)
qui meglm `var' b(1).treat##b(1).time##b(2).posttype i.female $sociod, family(poisson) link(log) vce(cluster pid)
est store `var'_mult2
outreg2 using `var'_discernment.xls, excel append label alpha(0.001, 0.01, 0.05)	

qui reg `var' b(1).treat##b(1).time##b(2).posttype i.female $sociod $cov, cluster(pid)
est store `var'_add3
outreg2 using `var'_discernment.xls, excel append label alpha(0.001, 0.01, 0.05)
qui meglm `var' b(1).treat##b(1).time##b(2).posttype i.female $sociod $cov, family(poisson) link(log) vce(cluster pid)
est store `var'_mult3
outreg2 using `var'_discernment.xls, excel append label alpha(0.001, 0.01, 0.05)

qui reg `var' b(1).treat##b(1).time##b(2).posttype i.female $sociod $cov $pers, cluster(pid)
est store `var'_add4
outreg2 using `var'_discernment.xls, excel append label alpha(0.001, 0.01, 0.05)
qui meglm `var' b(1).treat##b(1).time##b(2).posttype i.female $sociod $cov $pers, family(poisson) link(log) vce(cluster pid)
est store `var'_mult4
outreg2 using `var'_discernment.xls, excel append label alpha(0.001, 0.01, 0.05)		
}	

coefplot share__add4 reliable__add4 conf__add4 || share__mult4 reliable__mult4 conf__mult4, xline(0) keep(2.treat#2.time#1.posttype 3.treat#2.time#1.posttype)

coefplot share__add4 reliable__add4 conf__add4 || share__mult4 reliable__mult4 conf__mult4, xline(0) keep(cse_total pi_cultural_total pi_obedience_total pi_selfreport)

coefplot share__add4 reliable__add4 conf__add4 || share__mult4 reliable__mult4 conf__mult4, xline(0) keep(decep_total mach_total narc_total psych_total sadism_total)


** H4: Combined **

foreach var in share_ reliable_ conf_ {
	forval i = 1/2 {
		
qui reg `var' b(1).treat##b(1).time if posttype==`i', cluster(pid)
est store `var'_add_`i'
outreg2 using `var'_decomp.xls, excel append label alpha(0.001, 0.01, 0.05) ctitle("`var'_`i'")
qui meglm `var' b(1).treat##b(1).time if posttype==`i', family(poisson) link(log) vce(cluster pid)
est store `var'_mult_`i'
outreg2 using `var'_decomp.xls, excel append label alpha(0.001, 0.01, 0.05) ctitle("`var'_`i'")

qui reg `var' b(1).treat##b(1).time i.female $sociod if posttype==`i', cluster(pid)
est store `var'_add_`i'
outreg2 using `var'_decomp.xls, excel append label alpha(0.001, 0.01, 0.05) ctitle("`var'_`i'")
qui meglm `var' b(1).treat##b(1).time i.female $sociod if posttype==`i', family(poisson) link(log) vce(cluster pid)
est store `var'_mult_`i'
outreg2 using `var'_decomp.xls, excel append label alpha(0.001, 0.01, 0.05) ctitle("`var'_`i'")	

qui reg `var' b(1).treat##b(1).time i.female $sociod $cov if posttype==`i', cluster(pid)
est store `var'_add_`i'
outreg2 using `var'_decomp.xls, excel append label alpha(0.001, 0.01, 0.05) ctitle("`var'_`i'")
qui meglm `var' b(1).treat##b(1).time i.female $sociod $cov if posttype==`i', family(poisson) link(log) vce(cluster pid)
est store `var'_mult_`i'
outreg2 using `var'_decomp.xls, excel append label alpha(0.001, 0.01, 0.05) ctitle("`var'_`i'")

qui reg `var' b(1).treat##b(1).time i.female $sociod $cov $pers if posttype==`i', cluster(pid)
est store `var'_add_`i'
outreg2 using `var'_decomp.xls, excel append label alpha(0.001, 0.01, 0.05) ctitle("`var'_`i'")
qui meglm `var' b(1).treat##b(1).time i.female $sociod $cov $pers if posttype==`i', family(poisson) link(log) vce(cluster pid)
est store `var'_mult_`i'
outreg2 using `var'_decomp.xls, excel append label alpha(0.001, 0.01, 0.05) ctitle("`var'_`i'")		
	
	}
}	

** Figures 3a and 3b **

foreach var in  reliable_ share_ conf_ {
qui reg `var' b(1).treat##b(1).time##b(2).posttype i.female $sociod $cov $pers, cluster(pid)
est store `var'add4
}

** Individual coefficient plots: Figure 3a, right panel [Discernment (true - false)] **
coefplot reliable_add4, xline(0) keep(2.treat 3.treat 2.time 2.treat#2.time 3.treat#2.time 2.treat#2.time#1.posttype 3.treat#2.time#1.posttype female age edu cse_total pi_cultural_total pi_obedience_total pi_selfreport decep_total mach_total narc_total psych_total sadism_total) name(rel_add, replace) xscale(off)

coefplot share_add4, xline(0) keep(2.treat 3.treat 2.time 2.treat#2.time 3.treat#2.time 2.treat#2.time#1.posttype 3.treat#2.time#1.posttype female age edu cse_total pi_cultural_total pi_obedience_total pi_selfreport decep_total mach_total narc_total psych_total sadism_total) name(share_add, replace) xscale(off)

coefplot conf_add4, xline(0) keep(2.treat 3.treat 2.time 2.treat#2.time 3.treat#2.time 2.treat#2.time#1.posttype 3.treat#2.time#1.posttype female age edu cse_total pi_cultural_total pi_obedience_total pi_selfreport decep_total mach_total narc_total psych_total sadism_total) name(conf_add, replace)

graph combine rel_add share_add conf_add, cols(1) xcommon title("Discernment (true - false)", size(small))

** Individual coefficient plots: Figure 3a, left panel [Discernment decomposed] **
foreach var in  reliable_ share_ conf_ {
	forval i = 1/2 {
qui reg `var' b(1).treat##b(1).time i.female $sociod $cov $pers if posttype==`i', cluster(pid)
est store `var'`i'
	}
} 
coefplot reliable_1 reliable_2, xline(0) keep(2.treat 3.treat 2.time 2.treat#2.time 3.treat#2.time female age edu cse_total pi_cultural_total pi_obedience_total pi_selfreport decep_total mach_total narc_total psych_total sadism_total) recast(bar) barwidth(0.3) name(rel_dec, replace) legend(off) title("") xscale(off)
coefplot share_1 share_2, xline(0) keep(2.treat 3.treat 2.time 2.treat#2.time 3.treat#2.time female age edu cse_total pi_cultural_total pi_obedience_total pi_selfreport decep_total mach_total narc_total psych_total sadism_total) recast(bar) barwidth(0.3) name(share_dec, replace) legend(off) title("") xscale(off)
coefplot  conf_1 conf_2, xline(0) keep(2.treat 3.treat 2.time 2.treat#2.time 3.treat#2.time female age edu cse_total pi_cultural_total pi_obedience_total pi_selfreport decep_total mach_total narc_total psych_total sadism_total) recast(bar) barwidth(0.3) name(conf_dec, replace) legend(off)

** Figure 3 Combined **

graph combine rel_dec share_dec conf_dec, cols(1) xcommon title("Discernment decomposed", size(small))

graph combine fig3_decom.gph fig3_disc.gph


** Figure 4 **

foreach var in reliable_ share_ conf_ {
	foreach crt in creatavg mvalavg taskappavg fluavg {
qui reg `var' b(1).time##b(2).posttype##c.`crt' $creat i.female $sociod $cov $pers, cluster(pid)
est store `var'`crt'
	}
}

** Individual coefficient plots: Figures 4a-h, right panel [Discernment (true - false)] **
coefplot reliable_creatavg, xscale(off) || share_creatavg, xscale(off) || conf_creatavg, xline(0) keep(2.time creatavg mvalavg taskappavg fluavg 2.time#c.creatavg 2.time#1.posttype#c.creatavg female age edu cse_total pi_cultural_total pi_obedience_total pi_selfreport decep_total mach_total narc_total psych_total sadism_total) byopts(cols(1)) name(creat_disc) coeflabels(,labsize(small))

coefplot reliable_mvalavg, xscale(off) || share_mvalavg, xscale(off) || conf_mvalavg, xline(0) keep(2.time creatavg mvalavg taskappavg fluavg 2.time#c.mvalavg 2.time#1.posttype#c.mvalavg female age edu cse_total pi_cultural_total pi_obedience_total pi_selfreport decep_total mach_total narc_total psych_total sadism_total) byopts(cols(1)) name(mval_disc) coeflabels(,labsize(small))

coefplot reliable_taskappavg, xscale(off) || share_taskappavg, xscale(off) || conf_taskappavg, xline(0) keep(2.time creatavg mvalavg taskappavg fluavg 2.time#c.taskappavg 2.time#1.posttype#c.taskappavg female age edu cse_total pi_cultural_total pi_obedience_total pi_selfreport decep_total mach_total narc_total psych_total sadism_total) byopts(cols(1)) name(taskapp_disc) coeflabels(,labsize(small))

coefplot reliable_fluavg, xscale(off) || share_fluavg, xscale(off) || conf_fluavg, xline(0) keep(2.time creatavg mvalavg taskappavg fluavg 2.time#c.fluavg 2.time#1.posttype#c.fluavg female age edu cse_total pi_cultural_total pi_obedience_total pi_selfreport decep_total mach_total narc_total psych_total sadism_total) byopts(cols(1)) name(flu_disc) coeflabels(,labsize(small))


foreach var in reliable_ share_ conf_ {
	foreach crt in creatavg mvalavg taskappavg fluavg {
forval i = 1/2 {
qui reg `var' b(1).time##c.`crt' $creat i.female $sociod $cov $pers if posttype==`i', cluster(pid)
est store `var'`i'_`crt'
	}
}
}
** Individual coefficient plots: Figures 4a-h, left panel [Discernment decomposed] **

foreach var in reliable_ share_ conf_ {
foreach crt in creatavg mvalavg taskappavg fluavg {
coefplot `var'*_`crt', xline(0) keep(2.time creatavg mvalavg taskappavg fluavg 2.time#c.creatavg 2.time#c.mvalavg 2.time#c.taskappavg 2.time#c.fluavg female age edu cse_total pi_cultural_total pi_obedience_total pi_selfreport decep_total mach_total narc_total psych_total sadism_total) recast(bar) legend(off) title("") barwidth(0.3) name(`var'_`crt', replace) coeflabels(,labsize(small))
}
}

** Figures 4a-h combined **

graph combine reliable__creatavg share__creatavg conf__creatavg, rows(3) xcommon ycommon

graph combine fig4_decom.gph creat_disc, cols(2) ycommon

graph combine reliable__mvalavg share__mvalavg conf__mvalavg, rows(3) xcommon ycommon name(mval_decom, replace)

graph combine mval_decom mval_disc, cols(2) ycommon

graph combine reliable__taskappavg share__taskappavg conf__taskappavg, rows(3) xcommon ycommon name(taskapp_decom, replace)

graph combine taskapp_decom taskapp_disc, cols(2) ycommon

graph combine reliable__fluavg share__fluavg conf__fluavg, rows(3) xcommon ycommon name(flu_decom, replace)

graph combine flu_decom flu_disc, cols(2) ycommon



*2. Data Analyses - Non-Indian sample
restore
preserve
keep if nation==2

**H3: Discernment

foreach var in  reliable_ share_ conf_ {
qui reg `var' b(1).treat##b(1).time##b(2).posttype i.female $sociod $cov $pers, cluster(pid)
est store `var'add4
}

** Individual coefficient plots: Figure S3b, right panel [Discernment (true - false)] **
coefplot reliable_add4, xline(0) keep(2.treat 3.treat 2.time 2.treat#2.time 3.treat#2.time 2.treat#2.time#1.posttype 3.treat#2.time#1.posttype female age edu cse_total pi_cultural_total pi_obedience_total pi_selfreport decep_total mach_total narc_total psych_total sadism_total) name(reliable_us, replace) xscale(off) 

coefplot share_add4, xline(0) keep(2.treat 3.treat 2.time 2.treat#2.time 3.treat#2.time 2.treat#2.time#1.posttype 3.treat#2.time#1.posttype female age edu cse_total pi_cultural_total pi_obedience_total pi_selfreport decep_total mach_total narc_total psych_total sadism_total) xscale(off) name(share_us, replace)

coefplot conf_add4, xline(0) keep(2.treat 3.treat 2.time 2.treat#2.time 3.treat#2.time 2.treat#2.time#1.posttype 3.treat#2.time#1.posttype female age edu cse_total pi_cultural_total pi_obedience_total pi_selfreport decep_total mach_total narc_total psych_total sadism_total) name(conf_us)



foreach var in  reliable_ share_ conf_ {
	forval i = 1/2 {
qui reg `var' b(1).treat##b(1).time i.female $sociod $cov $pers if posttype==`i', cluster(pid)
est store `var'`i'
	}
}

** Individual coefficient plots: Figure S3a, left panel [Discernment decomposed] **
coefplot reliable_1 reliable_2, xline(0) keep(2.treat 3.treat 2.time 2.treat#2.time 3.treat#2.time female age edu cse_total pi_cultural_total pi_obedience_total pi_selfreport decep_total mach_total narc_total psych_total sadism_total) recast(bar) barwidth(0.3) legend(off) title("") xscale(off) name(rel_us_dec, replace)

coefplot share_1 share_2, xline(0) keep(2.treat 3.treat 2.time 2.treat#2.time 3.treat#2.time female age edu cse_total pi_cultural_total pi_obedience_total pi_selfreport decep_total mach_total narc_total psych_total sadism_total) recast(bar) barwidth(0.3) legend(off) title("") xscale(off) name(share_us_dec, replace)

coefplot  conf_1 conf_2, xline(0) keep(2.treat 3.treat 2.time 2.treat#2.time 3.treat#2.time female age edu cse_total pi_cultural_total pi_obedience_total pi_selfreport decep_total mach_total narc_total psych_total sadism_total) recast(bar) barwidth(0.3) legend(off) title("") name(conf_us_dec, replace)


** Figure S3a and b Combined **

graph combine rel_us_dec reliable_us share_us_dec share_us conf_us_dec conf_us, xcommon rows(3)

** Figure S4a to S4h **
foreach var in reliable_ share_ conf_ {
	foreach crt in creatavg mvalavg taskappavg fluavg {
qui reg `var' b(1).time##b(2).posttype##c.`crt' $creat i.female $sociod $cov $pers, cluster(pid)
est store `var'`crt'
	}
}

** Individual coefficient plots: Figures S4a-h, right panel [Discernment (true - false)] **
coefplot reliable_creatavg, xscale(off) || share_creatavg, xscale(off) || conf_creatavg, xline(0) keep(2.time creatavg mvalavg taskappavg fluavg 2.time#c.creatavg 2.time#1.posttype#c.creatavg female age edu cse_total pi_cultural_total pi_obedience_total pi_selfreport decep_total mach_total narc_total psych_total sadism_total) byopts(cols(1)) name(us_creat_disc) coeflabels(,labsize(small))

coefplot reliable_mvalavg, xscale(off) || share_mvalavg, xscale(off) || conf_mvalavg, xline(0) keep(2.time creatavg mvalavg taskappavg fluavg 2.time#c.mvalavg 2.time#1.posttype#c.mvalavg female age edu cse_total pi_cultural_total pi_obedience_total pi_selfreport decep_total mach_total narc_total psych_total sadism_total) byopts(cols(1)) name(us_mval_disc) coeflabels(,labsize(small))

coefplot reliable_taskappavg, xscale(off) || share_taskappavg, xscale(off) || conf_taskappavg, xline(0) keep(2.time creatavg mvalavg taskappavg fluavg 2.time#c.taskappavg 2.time#1.posttype#c.taskappavg female age edu cse_total pi_cultural_total pi_obedience_total pi_selfreport decep_total mach_total narc_total psych_total sadism_total) byopts(cols(1)) name(us_taskapp_disc) coeflabels(,labsize(small))

coefplot reliable_fluavg, xscale(off) || share_fluavg, xscale(off) || conf_fluavg, xline(0) keep(2.time creatavg mvalavg taskappavg fluavg 2.time#c.fluavg 2.time#1.posttype#c.fluavg female age edu cse_total pi_cultural_total pi_obedience_total pi_selfreport decep_total mach_total narc_total psych_total sadism_total) byopts(cols(1)) name(us_flu_disc) coeflabels(,labsize(small))

 

foreach var in reliable_ share_ conf_ {
	foreach crt in creatavg mvalavg taskappavg fluavg {
forval i = 1/2 {
qui reg `var' b(1).time##c.`crt' $creat i.female $sociod $cov $pers if posttype==`i', cluster(pid)
est store `var'`i'_`crt'
	}
}
}

** Individual coefficient plots: Figures S4a-h, left panel [Discernment decomposed] **
foreach var in reliable_ share_ conf_ {
foreach crt in creatavg mvalavg taskappavg fluavg {
coefplot `var'*_`crt', xline(0) keep(2.time creatavg mvalavg taskappavg fluavg 2.time#c.creatavg 2.time#c.mvalavg 2.time#c.taskappavg 2.time#c.fluavg female age edu cse_total pi_cultural_total pi_obedience_total pi_selfreport decep_total mach_total narc_total psych_total sadism_total) recast(bar) barwidth(0.3) legend(off) title("") name(us_`var'_`crt', replace)
}
}

** Combining graphs to form Figures S4a-h **
graph combine us_reliable__creatavg us_share__creatavg us_conf__creatavg, rows(3) xcommon ycommon name(us_creat_decom)

graph combine us_creat_decom us_creat_disc, cols(2) ycommon

graph combine us_reliable__mvalavg us_share__mvalavg us_conf__mvalavg, rows(3) xcommon ycommon name(us_mval_decom)

graph combine us_mval_decom us_mval_disc, cols(2) ycommon

graph combine us_reliable__taskappavg us_share__taskappavg us_conf__taskappavg, rows(3) xcommon ycommon name(us_taskapp_decom)

graph combine us_taskapp_decom us_taskapp_disc, cols(2) ycommon

graph combine us_reliable__fluavg us_share__fluavg us_conf__fluavg, rows(3) xcommon ycommon name(us_flu_decom)

graph combine us_flu_decom us_flu_disc, ycommon cols(2)
